Sync the window title initially
authorMatthias Clasen <mclasen@redhat.com>
Tue, 10 Dec 2013 23:44:26 +0000 (18:44 -0500)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 10 Dec 2013 23:44:26 +0000 (18:44 -0500)
When setting a custom titlebar that happens to be a GtkHeaderBar,
we connect to notify::title to pick up title changes on the headerbar,
but we forgot to sync the title initially. Fix that.

gtk/gtkwindow.c

index f1bc2f4e6d653fc8c3d0111f92fca2811879e837..d9490004e6cd58ff86cc3f51f03f060dde433fce 100644 (file)
@@ -3557,8 +3557,10 @@ on_titlebar_title_notify (GtkHeaderBar *titlebar,
                           GParamSpec   *pspec,
                           GtkWindow    *self)
 {
-  gtk_window_set_title_internal (self, gtk_header_bar_get_title (titlebar),
-                                 FALSE);
+  const gchar *title;
+
+  title = gtk_header_bar_get_title (titlebar);
+  gtk_window_set_title_internal (self, title, FALSE);
 }
 
 /**
@@ -3595,8 +3597,12 @@ gtk_window_set_titlebar (GtkWindow *window,
 
   priv->title_box = titlebar;
   gtk_widget_set_parent (priv->title_box, widget);
-  g_signal_connect (titlebar, "notify::title",
-                    G_CALLBACK (on_titlebar_title_notify), window);
+  if (GTK_IS_HEADER_BAR (titlebar))
+    {
+      g_signal_connect (titlebar, "notify::title",
+                        G_CALLBACK (on_titlebar_title_notify), window);
+      on_titlebar_title_notify (GTK_HEADER_BAR (titlebar), NULL, window);
+    }
 
   visual = gdk_screen_get_rgba_visual (gtk_widget_get_screen (widget));
   if (visual)